package com.site.core.rewrite;

import com.cnc.bas.util.Log;
import com.site.core.rewrite.type.RewriteType;
import com.site.core.translate.BingTranslate;
import com.site.core.translate.ContentTranslator;
import com.site.core.translate.TranslateType;

/**
 * 文章重写
 * @author Administrator
 *
 */
public class ContentRewriter {
	
	protected static Log  log = Log.getLogger(ContentRewriter.class);
	
	/**
	 * 对内容进行重写
	 * @param content
	 * @param type
	 * @return
	 */
	public static String rewrite(String content, RewriteType rewriteType, TranslateType translateType){
		String fromLang = rewriteType.getCurrLang();
		String toLang = rewriteType.getNextLang();
		String rewriteContent = null;
		while(toLang != null){
			log.logInfo("rewrite from:" + fromLang + " to:" + toLang + ".");
			rewriteContent = ContentTranslator.translate(content, fromLang, toLang, translateType);
			fromLang = rewriteType.getCurrLang();
			toLang = rewriteType.getNextLang();
		}
		
		return rewriteContent;
	}

}
